<template>
	<scroll-view scroll-y class="main" @scrolltolower="lower()">
		<view class="list" v-for="(item,index) of list">
			<image :src="oss(item.user.avatar)" class="cover" mode=""></image>
			<view class="info">
				<view class="title">
					<view class="l">{{item.user.nickname}}</view>
					<view class="r" v-if="item.status === 1">
						已完成
					</view>
					<view class="r" v-if="item.status === 0">
						已接单
					</view>
					<view class="r"  v-if="item.status === -1">
						已取消
					</view>
				</view>
				<view class="address">年龄：{{item.user.age}}</view>
				<view class="num">
					<view class="l" @click="tel(item.user.mobile)"><text class="type">电话：{{item.user.mobile}}</text><image src="../../../static/tel.png" mode="" class="tel"></image></view>
					<view class="r" v-if="item.status === 0" @click="sure(item.id)">完成</view>
					<view class="r" v-if="item.status === 0" @click="cancel(item.id)">取消</view>
				</view>
			</view>
		</view>
		
	</scroll-view>
</template>

<script>
	export default {
		data() {
			return {
				
				page: 1,
				finish: false,
				type: 0,
				list: [],
				show3: false,
				note: '',
				id: ''
			}
		},
			
		onLoad(options) {
			this.id = options.id
			this.getList()
		},
		methods: {
			sure(id) {
				uni.$u.http.post('/usercity', {
					id: id,
					types: 'finish'
				}).then(res => {
					if (res.code == 1) {
						uni.$u.toast(res.msg)
						this.reload()
					}
				}).catch((res) => {
						
				})
			},
			cancel(id) {
				uni.$u.http.post('/usercity', {
					id: id,
					types: 'cancel'
				}).then(res => {
					if (res.code == 1) {
						uni.$u.toast(res.msg)
						this.reload()
					}
				}).catch((res) => {
						
				})
			},
			tel(mobile) {
				uni.$u.http.post('/mobilelog',{
					mobile
				}).then(res => {
					if (res.code == 1) {
						uni.makePhoneCall({
							phoneNumber: mobile
						});
					}
				}).catch((res) => {
				
				})
			},
			toast(note) {
				this.note = note
				this.show3 = true
			},
			change(e) {
				console.log(e)
				this.type = e.type
				this.reload()
			},
			reload() {
				this.page = 1
				this.finish = false
				this.list = []
				this.getList()
			},
			lower() {
				this.page++
				this.getList()
			},
			getList() {
				if (this.finish) {
					return
				}
				uni.$u.http.post('/usercity', {
					id: this.id,
					page: this.page,
					types: 'user'
				}).then(res => {
					if (res.code == 1) {
						this.list = this.list.concat(res.data)
						if (res.data.length === 0) {
							this.finish = true
						}
					}
				}).catch((res) => {
		
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	page{
		height: 100%;
	}
.main{
	height: 100%;
	background: #f6f6f6;
	.list{
		display: flex;
		margin: 10rpx 20rpx;
		padding: 20rpx;
		background-color: #fff;
		border-radius: 10rpx;
		position: relative;
		.cover{
			width: 120rpx;
			height: 120rpx;
			margin-right: 20rpx;
			flex-direction: 0;
			border-radius: 50%;
		}
		.address{
			font-size: 25rpx;
			color: #575859;
			margin: 10rpx 0 20rpx;
		}
		.info{
			flex: 1;
			.title{
				display: flex;
				align-items: center;
				.l{
					flex: 1;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
					font-weight: bold;
				}
				.r{
					color: #428DFC;
					font-size: 24rpx;
					flex-shrink: 0;
					display: flex;
					align-items: center;
				}
			}
			.num{
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 20rpx;
				.l{
					display: flex;
					align-items: center;
					.type{
						color: #666;
						font-size: 24rpx;
					}
					.word{
						background-color: #FFFAE5;
						height: 36rpx;
						border-radius: 18rpx;
						color: #FF8007;
						font-size: 20rpx;
						padding: 0 20rpx;
						display: flex;
						align-items: center;
					}
					.tel{
						width: 36rpx;
						height: 36rpx;
						margin-left: 20rpx;
					}
				}
				.r{
					color: #666;
					font-size: 28rpx;
				}
			}
		}
	}
}
</style>
